<?php

class MsgTemplateAction extends CommonAction{
public function index()
{
$tpl_list = M('MsgTemplate')->findAll();
$this->assign('tpl_list',$tpl_list);
$this->display();
}
public function load_tpl()
{
$name = trim($_REQUEST['name']);
$tpl = M('MsgTemplate')->where("name='".$name."'")->find();
if($tpl)
{
$tpl['tip'] = l('MSG_TIP_'.strtoupper($name));
$this->ajaxReturn($tpl,'',1);
}
else
{
$this->ajaxReturn('','',0);
}
}
public function update()
{
$data = M(MODULE_NAME)->create ();
if($data['name']==''||$data['id']==0)
{
$this->error(l('SELECT_MSG_TPL'));
}
$log_info = $data['name'];
$this->assign('jumpUrl',u(MODULE_NAME.'/index'));
$list=M(MODULE_NAME)->save ($data);
if (false !== $list) {
save_log($log_info.L('UPDATE_SUCCESS'),1);
$this->success(L('UPDATE_SUCCESS'));
}else {
save_log($log_info.L('UPDATE_FAILED'),0);
$this->error(L('UPDATE_FAILED'),0,$log_info.L('UPDATE_FAILED'));
}
}
}
?>